import Component from '@glimmer/component';
import { service } from '@ember/service';

export default class MapViewComponent extends Component {
  @service call;

  constructor() {
    super(...arguments);
    // 获取地图apikey
    this.call.getCached('/api/config/amap.KeyAndCode').then((res) => {
      if (res.success) {
        var data = JSON.parse(res.data.value);
        this.amapKey = data.amapKey;

        this.mapIframe.src =
          'https://m.amap.com/navi/?dest=' +
          this.args.longitude +
          ',' +
          this.args.latitude +
          '&destName=' +
          this.args.name +
          '&hideRouteIcon=1' +
          '&' +
          this.amapKey;
      }
    });
  }
}
